using Microsoft.Extensions.Configuration;

namespace MultiAgentsClient.Service;

public class ServerIPConfig
{
    public List<string> ServerName { get; set; } = [];
    public List<string> ServerIp { get; set; } = [];
}

public class Port
{
    public string LocalDev { get; set; } = "";
    public string Develop { get; set; } = "";
    public string Release { get; set; } = "";
}

public class AppSettings
{
    public ServerIPConfig ServerIPConfig { get; set; } = new();
    public Port Port { get; set; } = new();
}

public class AppConfigService
{
    private static readonly IConfiguration _configuration = new ConfigurationBuilder()
            .SetBasePath(Directory.GetCurrentDirectory())
            .AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.json"), optional: false, reloadOnChange: true).Build();

    public static T GetSection<T>(string key) where T : new()
    {
        var section = new T();
        _configuration.GetSection(key).Bind(section);
        return section;
    }
}
